﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace TarreOA.TarreOADAL {
    public class FlowFront_WorkInfo_DAO {
        /// <summary>
        /// 根据指定条件查询待办工作中需要显示的工作内容
        /// </summary>
        /// <param name="sql">要执行查询的sql语句</param>
        /// <param name="sqlParas">参数键值对集合</param>
        /// <returns></returns>
        public SqlDataReader FindWorkInfos(string sql, Hashtable sqlParas, SqlConnection sqlConn) {
            SqlCommand sqlCmd = null;
            SqlDataReader sqlDr = null;
            try {
                if(sqlConn.State != ConnectionState.Open) {
                    sqlConn.Open();
                }
                sqlCmd = new SqlCommand(sql, sqlConn);
                foreach(object key in sqlParas.Keys) {
                    sqlCmd.Parameters.Add(new SqlParameter(key.ToString(), sqlParas[key]));
                }
                sqlDr = sqlCmd.ExecuteReader();
            } catch(Exception ex) {
                Console.WriteLine(ex.Message);
                if(sqlDr != null) {
                    sqlDr.Close();
                    sqlDr.Dispose();
                }
            } finally {
            }
            return sqlDr;
        }
    }
}
